package model;

import java.util.ArrayList;
import java.util.HashMap;


public class Sentence {
	/**
	 * @uml.property  name="no"
	 */
	int no;
	/**
	 * @uml.property  name="wordMap"
	 * @uml.associationEnd  qualifier="word:java.lang.String Word"
	 */
	HashMap <String,Word> wordMap ;// holds words in the sentence
	
	
	public Sentence(int no) {
		super();
		this.no = no;
		this.wordMap = new HashMap <String,Word>();
	}
	public int calcPairOccurence(WordPair pair){//  calculates the pair occurence
		int occ1=0;
		int occ2=0;
		
		if(wordMap.containsKey(pair.first) && wordMap.containsKey(pair.second)){
			occ1=getWordMap().get(pair.first).getWordOccInSentence().get(getNo()).intValue();
			occ2=getWordMap().get(pair.second).getWordOccInSentence().get(getNo()).intValue();
		
		}else{
			return 0;
		}
		
		if(occ1 >= occ2){
			return occ2;
		}
		else{
			return occ1;
		}
	}
	public int getWordOccurence(String word){
		int occ=0;
		if(wordMap.containsKey(word)){
			
			occ=wordMap.get(word).getWordOccInSentence().get(no).intValue();
		}
		return occ;
		
	}
	/**
	 * @return
	 * @uml.property  name="no"
	 */
	public int getNo() {
		return no;
	}
	/**
	 * @param no
	 * @uml.property  name="no"
	 */
	public void setNo(int no) {
		this.no = no;
	}
	public HashMap<String, Word> getWordMap() {
		return wordMap;
	}
	public void setWordMap(HashMap<String, Word> wordMap) {
		this.wordMap = wordMap;
	}
	
}
